//2009/08/22 17:19:08
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class Trekking
{
public:
    int findCamps(string trail, vector <string> plans)
    {
		int ret = -1;
		for(int i=0; i<plans.size(); i++)
		{
			bool flag = true;
			int cnt = 0;
			for(int j=0; j<trail.size(); j++)
			{
				if(trail[j] == '^' && plans[i][j]=='C')
				{
					flag = false;
					cout << plans[i] << endl;
					break;
				}
				if(plans[i][j] == 'C') cnt++;
			}
			if(flag) 
			{
				if(cnt < ret || ret == -1)
					ret = cnt;
			}
		}
		return ret;
    }
};
